﻿using System;
using System.Collections;
using System.Collections.Generic;
using com.yoozoo.gta.Gameplay.PVE;
using Gameplay.PVE.Survivor;
using OWL.Rendering.HRP;
using UnityEngine;
using UnityEngine.AI;
using Yoozoo.Gameplay.Liberty;
using Yoozoo.HRP.Runtime;

[Serializable]
public class BattleMapMonster
{
    public Vector3 position;
    public Vector3 forward;
    public int heroId;
    public EEnemyAIType aiType;
    public float searchRange;
    public bool transmitToGroup;
    public EMapUnitType unitType;
    public int pointId;

    public bool isPatrol;
    public string extraParam1;
    public string extraParam2;
    public float attributeRatio = 1;
    public int team = 2;

    public int specialIndex;
}

[Serializable]
public class BattleMapMonsterGroup
{
    public int id;
    public int fogId;
    public List<BattleMapMonster> monsters;
}

[Serializable]
public class BattleMapScene
{
    public string mapPrefabName;
    public string renderSettingName;
    public string lightElementName;
}

[Serializable]
public class BattleMapPoint
{
    public int id;
    public Vector3 position;
    public Vector3 forward;
}

[Serializable]
public class BattleMapRegion
{
    public int id;
    public Vector3 position;
    public Vector3 forward;
    public int shape;
    public float shapeParam1;
    public float shapeParam2;
}

[Serializable]
public class BattleMapInteractableEvent
{
    [Tooltip(@"
参数说明
PlayerAnimation(人物动画)
    1.动作名称
    2.角色索引
SelfAnimation(交互物动画)
    1.动作名称
PlayerMoveTo(移动)
    1.点位
    2.角色索引
CameraShake(相机震动)
    1.时长
FlyText(飘字)
    1.飘字类型
    2.间隔
    3.点位
    4.内容
TriggerEvent(触发事件)
    1.事件id
TimeScale(子弹时间)
    1.缩放倍率
    2.进入时长
    3.持续时间
    4.退出时长
ChangeCameraFollow(CM的FollowOffset)
    1.值
    2.进入时间
    3.持续时间
    3.退出时间
ChangeCameraTrack(CM的TrackOffset)
    1.值
    2.进入时间
    3.持续时间
    3.退出时间
ShowHud(显示交互状态Hud)
    1.标题
ShowBubble(显示对话气泡)
    1.内容
    2.角色阵营
    3.角色标识(如果是我方，则为角色索引
              如果是敌方，则为怪物身上的标识id)
    4.朝向（0箭头在左，1箭头在右）
JoinTeam(加入队伍)
    1.角色阵营
    2.角色标识
"
        )]
    public EBattleInteractableEvent eventType;
    public string param;
    public string param2;
    public string param3;
    public string param4;
    public float startTime;
    public float endTime;
}

[Serializable]
public class MapRoute
{
    public int id;
    public List<Vector3> points = new List<Vector3>();
}

[Serializable]
public class MapTruckPath
{
    public List<MapTruckPathPoint> points = new List<MapTruckPathPoint>();
}

[Serializable]
public class MapTruckPathPoint
{
    public Vector3 pos;
    public float time;
    public float angle;
}

public class BattleMapData : MonoBehaviour
{
    public BattleMapScene scene;
    public List<BattleMapMonsterGroup> monsterGroup;
    public List<BattleMapPoint> points;
    public List<BattleMapRegion> regions;
    public List<MapInteractableData> interactables;
    public List<MapObstacleData> obstacles;
    public List<MapRoute> routes;
    public List<MapTruckPath> truckPath;
    public MapFogGroup fog;
    public NavMeshData navMeshData;
    public List<Vector2> spawnPoints;
    public float spawnPointGridSize = 2f;
    public List<Vector2> spawnSafePoints;
    
    public int deckPointId;
    
    private void OnDrawGizmos()
    {
#if UNITY_EDITOR
        var parent = transform.Find("SpawnRegion");
        if (parent != null)
        {
            for (int i = 0; i < parent.childCount; i++)
            {
                var region = parent.GetChild(i);
                for (int j = 0; j < region.childCount; j++)
                {
                    var point = region.GetChild(j);
                    var nextPoint = region.GetChild((j + 1) % region.childCount);
                    Gizmos.DrawLine(point.position,nextPoint.position);
                }
            }
        }
#endif
    }
}


